<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="${root!}/static/css/layout.css" rel="stylesheet" type="text/css" />
<link href="${root!}/static/css/skin.css" rel="stylesheet" type="text/css" />
<link href="${root!}/static/css/dialog.css" rel="stylesheet" type="text/css" />
<link href="${root!}/static/css/tab.css" rel="stylesheet" type="text/css" />

<script src="${root!}/static/Js/jquery-1.4.2.js" type="text/javascript"></script>

<script src="${root!}/static/js/layout.js" type="text/javascript"></script>

<script src="${root!}/static/js/dialog.js" type="text/javascript"></script>

<script src="${root!}/static/js/tab.js" type="text/javascript"></script>

<script src="${root!}/static/js/row.js" type="text/javascript"></script>

<script src="${root!}/static/js/form.js" type="text/javascript"></script>

<script>
	var RootPath = "${root!}";
	var FormCodeUrl = RootPath + "/form/formColumn";
	var FormSubmitMethod = "save";
	var FormSubmitAction = "${action!}";
	
	$(function() {
		HideTab("tab5");
        
        //控件初始化
        var inheritParent="${bean.inheritParent!}";
        if(inheritParent=="1")
        {
        	$("#rdoInheritParent1").attr("checked","true");
        }
        else if(inheritParent=="0")
        {
        	$("#rdoInheritParent2").attr("checked","true");
        }
            
        ProcessTab();
        
	});
	
	function ProcessTab(pageCode) {
		ShowTab("tab5");
    }
	
	function SubmitClick() {
		if (!CheckForm()) {
			return false;
		} else {
			SubmitForm();
		}
	}

	function SelectForm()
	{
		var currentId = document.getElementById("hidFormId").value;
        
        var dataMapper = "form.form.selectTree";
        var searchObject={};
        searchObject.pageClassifyCode="lby";
        var searchMapper = JSON.stringify(searchObject);
        searchMapper = searchMapper.replace(/\%/g, "%25");
        searchMapper = searchMapper.replace(/\+/g, "%2B");
        searchMapper = searchMapper.replace(/\&/g, "%26");
        searchMapper = encodeURIComponent(searchMapper);
        CommonDialog("/components/tree/treeDialog?selectType=1&expandType=1&currentId="+currentId+"&dataMapper="+dataMapper+"&searchMapper="+searchMapper, "选择表单", 600, 400, function(v) {

            var returnObj = eval("(" + unescape(v) + ")");
            if (returnObj) {

            	var nodeId=returnObj.NodeId;
            	var nodeText=returnObj.NodeText;
            	
        		$("#hidFormId").val(nodeId);
        		$("#txtFormName").val(nodeText);

            	var formId=$("#hidFormId").val();
            	var parentTableId=getTableByFormId(formId);
            	$("#hidParentTableId").val(parentTableId);
            }

        });
	}
	
	function getTableByFormId(formId)
	{
		var ret="";
		
		$.ajax({
			type : "GET",
			async: false,
			url : FormCodeUrl + "/getTableByFormId?formId=" + formId,
			success : function(msg) {
				ret=msg;
			}
		});
		
		return ret;
	}
	
	
	function SelectReadField()
	{
		var currentId = document.getElementById("hidReadFieldId").value;
	
		var dataMapper = "frame.field.selectTree";
        var searchObject={};
        searchObject.tableId=$("#hidParentTableId").val();
        searchObject.multiValueKey="tableId";
        var searchMapper = JSON.stringify(searchObject);
        searchMapper = searchMapper.replace(/\%/g, "%25");
        searchMapper = searchMapper.replace(/\+/g, "%2B");
        searchMapper = searchMapper.replace(/\&/g, "%26");
        searchMapper = encodeURIComponent(searchMapper);
        
        CommonDialog("/components/tree/treeDialog?selectType=1&expandType=1&onlyLeafSelect=true&currentId="+currentId+"&dataMapper="+dataMapper+"&searchMapper="+searchMapper, "选择字段", 600, 400, function(v) {

            
        	var ids="";
        	var texts="";
        	var parentIds="";
        	var parentTexts="";
        	if(v.length>0)
        	{
        		var selectArray = v.split(",");
        		for (var i = 0; i < selectArray.length; i++) {
        			var selectItem = selectArray[i];
        			
        			var returnObj = eval("(" + unescape(selectItem) + ")");
        			if (returnObj) {
       				 	ids += ",";
                        ids += returnObj.NodeId;
                        texts += ",";
                        texts += (returnObj.ParentNodeText+"."+returnObj.NodeText);
                        parentIds += ",";
                        parentIds += returnObj.ParentNodeId;
                        parentTexts += ",";
                        parentTexts += returnObj.ParentNodeText;
       			 	}
        	
        		}
        		if (ids.length > 0) {
                    ids = ids.substring(1);
                    texts = texts.substring(1);
                    parentIds = parentIds.substring(1);
                    parentTexts = parentTexts.substring(1);
                }
            	$("#hidReadFieldId").val(ids);
            	$("#txtReadFieldName").val(texts);
            	$("#hidReadTableId").val(parentIds);
            	$("#hidReadTableName").val(parentTexts);
        	}
        	

        });
	}
	
</script>

</head>
<body>
	<form id="myform">
		<div class="container">
			<div class="fullwidth">
				<div class="buttonGroup h30">
					<input type="button" value="确定" id="btnSubmit"
						onclick="SubmitClick();" /> <input type="button" value="取消"
						id="btnInsert" onclick="CloseWindow();" />
				</div>
			</div>
			<div class="hiddencalc fullwidth h4"></div>

	        <div class="tabGroup fullwidth">
	            <div class="tab fullheight selected" id="tab1" target="page1">
	                <span class="tableft"></span><font>基本信息</font><span class="tabright"><span class="hiddencalc inputresult init"></span></span>
	            </div>
	            <div class="tab fullheight" id="tab5" target="page5">
	                <span class="tableft"></span><font>扩展信息</font><span class="tabright"><span class="hiddencalc inputresult init"></span></span>
	            </div>
	        </div>

			<div class="hiddencalc fullwidth h4"></div>
			<div class="fullwidth calcheight onlyscrolly" id="page1">
				<div class="formcontainer calcwidth">
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">列表编号：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtFormColumnId"
								name="txtFormColumnId" value="${bean.formColumnId!}" readonly />
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">列表名称：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtFormColumnTitle"
								name="txtFormColumnTitle" value="${bean.formColumnTitle!}" /><span
								class="hiddencalc inputresult init" minlength="1" maxlength="50"
								controlname="列表名称" bindcontrol="txtFormColumnTitle"></span>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">列表容器：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtFormName"
								name="txtFormName" value="${formName!}" readonly />
							<font><a href="javascript:void(0);" onclick="SelectForm()">【选择】</a></font>
							<input type="hidden" id="hidFormId" name="hidFormId" value="${bean.formId!}" />
							<span class="hiddencalc inputresult init" minlength="1"
								controlname="保存表" bindcontrol="txtFormName"></span>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">继承父项：</font>
						</div>
						<div class="control calcwidth">
							<input type="radio" id="rdoInheritParent1" name="rdoInheritParent" value="1"  />
							<font>是</font>
							<input type="radio" id="rdoInheritParent2" name="rdoInheritParent" value="0" />
							<font>否</font>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">顺序号：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtOrderNumber"
								name="txtOrderNumber" value="${bean.orderNumber!}" /><span
								class="hiddencalc inputresult init" validateregular="数字"
								minlength="1" maxlength="50" controlname="顺序号"
								bindcontrol="txtOrderNumber"></span>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">相关字段：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtReadFieldName"
								name="txtReadFieldName" value="${readFieldName!}" readonly />
							<font><a href="javascript:void(0);" onclick="SelectReadField()">【选择】</a></font>
							<input type="hidden" id="hidReadFieldId" name="hidReadFieldId" value="${readFieldId!}" />
							<input type="hidden" id="hidReadTableId" name="hidReadTableId" value="${readTableId!}" />
							<input type="hidden" id="hidReadTableName" name="hidReadTableName" value="${readTableName!}" />
							<input type="hidden" id="hidParentTableId" name="hidParentTableId" value="${parentTableId!}" />
							<span class="hiddencalc inputresult init" minlength="1"
								controlname="相关字段" bindcontrol="txtReadFieldName"></span>
						</div>
					</div>


				</div>
				<div class="scrollwidth hiddencalc" style="display: none;">
					<!--滚动条占位宽度-->
				</div>
			</div>
			
			<div class="fullwidth calcheight onlyscrolly" id="page5">
				<input type="hidden" id="hidFormParamIds" name="hidFormParamIds" value="${formParamIds!}" />
				<table border="1" width="100%" id="ParamRow1" class="showDataTable" cellspacing="0">
					<#if listFormParams??><#list listFormParams as m>
					<tr class="showDataRow" id="row_${m.ParamsId!}">
						<td width="80">${m.ParamsCode!}：</td>
						<td width="400">
							${m.Control!}
						</td>
						<td>
							${m.ParamsText!}
							${m.Script!}
							<input type="hidden" id="hidParamsId" name="hidParamsId" />
						</td>
					</tr>
					</#list></#if>
				</table>
			</div>
		</div>
	</form>
</body>
</html>
